package com.ly.heart.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.ly.common.core.domain.AjaxResult;
import com.ly.common.exception.CustomException;
import com.ly.common.utils.DateUtils;
import com.ly.common.utils.SecurityUtils;
import com.ly.common.utils.erp.SnowflakeIdWorker;
import com.ly.heart.mapper.KingFinancePayDetailMapper;
import com.ly.heart.service.IKingFinancePayDetailService;
import org.springframework.stereotype.Service;
import com.ly.heart.domain.KingFinancePayDetailEntity;

import javax.annotation.Resource;

/**
 * 财务模块-付款、收款、付款退款、收款退款，明细列Service业务层处理
 *
 * @author wutao
 * @date 2024-07-12
 */
@Service
public class KingFinancePayDetailServiceImpl extends ServiceImpl<KingFinancePayDetailMapper, KingFinancePayDetailEntity> implements IKingFinancePayDetailService {

    @Resource
    private KingFinancePayDetailMapper kingFinancePayReceiptDetailEntityMapper;

    /**
     * 查询财务模块-付款、收款、付款退款、收款退款，明细列列表
     *
     * @param kingFinancePayDetailEntity 财务模块-付款、收款、付款退款、收款退款，明细列
     * @return 财务模块-付款、收款、付款退款、收款退款，明细列
     */
    @Override
    public List<KingFinancePayDetailEntity> selectKingFinancePayReceiptDetailEntityList ( KingFinancePayDetailEntity kingFinancePayDetailEntity ) {
        return kingFinancePayReceiptDetailEntityMapper.selectKingFinancePayReceiptDetailEntityList ( kingFinancePayDetailEntity );
    }

    /**
     * 新增财务模块-付款、收款、付款退款、收款退款，明细列
     *
     * @param kingFinancePayDetailEntity
     * @return 结果
     */
    @Override
    public AjaxResult insertKingFinancePayReceiptDetailEntity ( KingFinancePayDetailEntity kingFinancePayDetailEntity ) {
        kingFinancePayDetailEntity.setId ( SnowflakeIdWorker.getInstance ().nextStringId () );
        kingFinancePayDetailEntity.setCreateBy ( SecurityUtils.getLoginUser ().getUser ().getUserId () );
        kingFinancePayDetailEntity.setCreateTime ( DateUtils.getNowDate () );
        boolean save = this.save ( kingFinancePayDetailEntity );
        if ( ! save ) {
            throw new CustomException ( "更新付款单明细行失败！" );
        }
        return AjaxResult.success ();
    }

}
